package cn.kuporo.seckill.stock.domain.model.entity;

import cn.kuporo.seckill.common.utils.SnowFlakeFactory;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: kuporo
 * @since: 2025/7/18
 * @description: 商品库存分桶
 */
@Data
@NoArgsConstructor
public class SeckillStockBucket {
    /**
     * 数据主键id
     */
    private Long id;

    /**
     * 商品id
     */
    private Long goodsId;

    /**
     * 初始库存
     */
    private Integer initialStock;

    /**
     * 当前可用库存
     */
    private Integer availableStock;

    /**
     * 状态，0: 不可用; 1:可用
     */
    private Integer status;

    /**
     * 分桶编号
     */
    private Integer serialNo;
    public SeckillStockBucket(Long goodsId, Integer initialStock, Integer availableStock, Integer status, Integer serialNo) {
        this.id = SnowFlakeFactory.getSnowFlakeFromCache().nextId();
        this.goodsId = goodsId;
        this.initialStock = initialStock;
        this.availableStock = availableStock;
        this.status = status;
        this.serialNo = serialNo;
    }
}
